// promise.all 使⽤，特点，发⽣错误如何不影响后续异步任务执⾏
/**
 * 对promise.all中的每个promise单独catch
 */

const errorPromise = () => Promise.reject(new Error('reject'))
const successPromise = () => Promise.resolve('success')

const allPromise = () => {
  return Promise.all([
    successPromise().catch(error => { console.log('successPromise catch', error) }),
    errorPromise().catch(error => { console.log('errorPromise catch', error) })
  ])
    .then(res => {
      console.log('allPromise success', res)
    }).catch(error => {
      console.log('allPromise error', { error })
    })
}

allPromise()
